import {Component, OnInit} from "@angular/core";
import {Hero} from "../../models/hero";
import {HeroesService} from "../../services/heroes.service";
import {Router} from "@angular/router";

@Component({
  selector: 'dashboard',
  templateUrl: './dashboard.component.html',
  styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
  private topHeroes: Hero[] = []

  constructor(private service: HeroesService,
              private router: Router) {
  }

  ngOnInit() {
    this.service.getHeroes().subscribe(heroes => {
      this.topHeroes = heroes.slice(1, 5)
    })
  }

  gotoDetail(hero: Hero) {
    this.router.navigate(['/detail', hero.id])
  }

}
